/*
 * @Description: api相关配置
 * @Date: 2021-03-04 11:15:07
 * @Author: 黄治恩
 */

import axios from 'axios'

let baseURL: string = ''

const service = axios.create({
  baseURL,
  headers:{},
  timeout:30000
})

// 请求前拦截
service.interceptors.request.use( config => {
  return config
}, error => {
  Promise.resolve(error)
})

// 返回后拦截
service.interceptors.response.use( response => {
  // 错误处理
  // if(error){
  //   let { code, msg, data } = response.data
    
  //   return Promise.reject(new Error(msg))
  // }
  // 正常返回
  return response.data;
}, error => {
  console.log('error',error);
  return Promise.reject(error);
})

export default service